﻿<sap:ActivityDesigner x:Class="Wilke.Interactive.Drone.Extensions.Activities.PilotDesigner"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:s="clr-namespace:System;assembly=mscorlib" 
                      xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
                      xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
                      xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:widc="clr-namespace:Wilke.Interactive.Drone.Control.Enumerations;assembly=Wilke.Interactive.Drone.Control" 
                      mc:Ignorable="d" d:DesignHeight="190" d:DesignWidth="307">
    <sap:ActivityDesigner.Icon>
        <DrawingBrush>
            <DrawingBrush.Drawing>
                <ImageDrawing>
                    <ImageDrawing.Rect>
                        <Rect Location="0,0" Size="25,25" ></Rect>
                    </ImageDrawing.Rect>
                    <ImageDrawing.ImageSource>
                        <BitmapImage UriSource="pack://application:,,,/Wilke.Interactive.Drone.Extensions;component/resources/icons/pilot1.png" ></BitmapImage>
                    </ImageDrawing.ImageSource>
                </ImageDrawing>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </sap:ActivityDesigner.Icon>
    <sap:ActivityDesigner.Resources>
        <ResourceDictionary x:Uid="ResourceDictionary"> 
            <Style TargetType="Border" x:Key="Header">
                <Style.Setters>
                    <Setter Property="Background" Value="Silver"/>
                    <Setter Property="BorderBrush" Value="Black"/>
                    <Setter Property="BorderThickness" Value="1"/>
                </Style.Setters>
            </Style>
            <Style TargetType="Border" x:Key="Row">
                <Style.Setters>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="BorderBrush" Value="Black"/>
                </Style.Setters>
            </Style>
            <DataTemplate x:Key="Collapsed">
                <Grid>                    
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="0"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Roll
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="1"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Pitch
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="2"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Height
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="3"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Yaw
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="4"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Duration
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Header}"
                            Grid.Column="5"
                            Grid.Row="0">
                        <Label HorizontalAlignment="Center">
                            Compensate
                        </Label>
                    </Border>

                    <Border Style="{StaticResource Row}"
                            Grid.Column="0"
                            Grid.Row="1">
                        <Label HorizontalAlignment="Center"
                           Content="{Binding Path=ModelItem.Roll}">
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Row}"
                            Grid.Column="1"
                            Grid.Row="1">
                        <Label HorizontalAlignment="Center"
                           Content="{Binding Path=ModelItem.Pitch}">
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Row}"
                            Grid.Column="2"
                            Grid.Row="1">
                        <Label HorizontalAlignment="Center"
                           Content="{Binding Path=ModelItem.Height}">
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Row}"
                            Grid.Column="3"
                            Grid.Row="1">
                        <Label HorizontalAlignment="Center"
                           Content="{Binding Path=ModelItem.Yaw}">
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Row}"
                            Grid.Column="4"
                            Grid.Row="1">
                        <Label HorizontalAlignment="Center"
                           Content="{Binding Path=ModelItem.Duration}">
                        </Label>
                    </Border>
                    <Border Style="{StaticResource Row}"
                            Grid.Column="5"
                            Grid.Row="1">
                        <CheckBox IsChecked="{Binding Path=ModelItem.Compensate, Mode=TwoWay}"
                                  Margin="0 6 0 0"
                                  HorizontalAlignment="Center"
                                  IsEnabled="False">
                        </CheckBox>
                    </Border>
                </Grid>
            </DataTemplate>
            <DataTemplate x:Key="Expanded">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"/>
                        <ColumnDefinition Width="100"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock 
                        VerticalAlignment="Center" 
                        Grid.Row="0"
                        Grid.Column="0"
                        Margin="5">
                        Roll (Tilt Left/Right)
                    </TextBlock>
                    <TextBox
                        Text="{Binding Path=ModelItem.Roll, Mode=TwoWay}"
                        PreviewTextInput="TextBox_PreviewTextInput"
                        TextAlignment="Right"
                        Height="23"
                        Margin="0, 0, 5, 0"
                        Grid.Row="0"
                        Grid.Column="1"
                        MaxLines="1">
                    </TextBox>
                    <TextBlock             
                        VerticalAlignment="Center"             
                        Grid.Row="1"            
                        Grid.Column="0"            
                        Margin="5" >            
                        Pitch (Tilt Front/Back)
                    </TextBlock>
                    <TextBox
                        Text="{Binding Path=ModelItem.Pitch, Mode=TwoWay}"
                        PreviewTextInput="TextBox_PreviewTextInput"
                        TextAlignment="Right"
                        Height="23"
                        Margin="0, 0, 5, 0"
                        Grid.Row="1"
                        Grid.Column="1"
                        MaxLines="1">
                    </TextBox>
                    <TextBlock 
                        Name="txtCenter"
                        VerticalAlignment="Center" 
                        Grid.Row="2"
                        Grid.Column="0"
                        Margin="5">
                        Height
                    </TextBlock>
                    <TextBox
                        Text="{Binding Path=ModelItem.Height, Mode=TwoWay}"
                        PreviewTextInput="TextBox_PreviewTextInput"
                        TextAlignment="Right"
                        Height="23"
                        Margin="0, 0, 5, 2"
                        Grid.Row="2"
                        Grid.Column="1"
                        MaxLines="1">
                    </TextBox>
                    <TextBlock 
                        Name="txtYaw"
                        VerticalAlignment="Center" 
                        Grid.Row="3"
                        Grid.Column="0"
                        Margin="5">
                        Yaw (Rotate Left/Right)
                    </TextBlock>
                    <TextBox
                        Text="{Binding Path=ModelItem.Yaw, Mode=TwoWay}"
                        PreviewTextInput="TextBox_PreviewTextInput"
                        TextAlignment="Right"
                        Height="23"
                        Margin="0, 0, 5, 2"
                        Grid.Row="3"
                        Grid.Column="1"
                        MaxLines="1">
                    </TextBox>
                    <TextBlock 
                        Name="txtDuration"
                        VerticalAlignment="Center" 
                        Grid.Row="4"
                        Grid.Column="0"
                        Margin="5">
                        Duration (seconds)
                    </TextBlock>
                    <TextBox
                        Text="{Binding Path=ModelItem.Duration, Mode=TwoWay}"
                        PreviewTextInput="TextBox_PreviewTextInput"
                        TextAlignment="Right"
                        Height="23"
                        Margin="0, 0, 5, 2"
                        Grid.Row="4"
                        Grid.Column="1"
                        MaxLines="1">
                    </TextBox>
                    <TextBlock 
                        Name="txtCompensate"
                        VerticalAlignment="Center" 
                        Grid.Row="6"
                        Grid.Column="0"
                        Margin="5">
                        Compensate
                    </TextBlock>
                    <CheckBox IsChecked="{Binding Path=ModelItem.Compensate, Mode=TwoWay}"
                              Grid.Row="5"
                              Grid.Column="1"
                              Margin="0 6 0 0">                        
                    </CheckBox>
                </Grid>
            </DataTemplate>
            <Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
                <Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="false">
                        <Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </sap:ActivityDesigner.Resources>
    <Grid>
        <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />
    </Grid>
</sap:ActivityDesigner>
